package com.hq.fxh.No2_BBS.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.hq.fxh.No2_BBS.Fragment.BBS_Plate_Fragment;
import com.hq.fxh.R;

public class PlateSelectActivity extends AppCompatActivity {

    protected TextView tvPlateSeclecBack;
    protected FrameLayout fragmentPlateSelect;
    protected int firstSort = 1;
    protected int secondSort = 1;
    protected String firstSortName, secondSortName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.activity_plateselect);
        initView();
        initData();
    }

    private void initData() {
        tvPlateSeclecBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setResult(1001, null);
                finish();
            }
        });
    }

    private void initView() {
        tvPlateSeclecBack = (TextView) findViewById(R.id.tv_PlateSeclec_Back);
        fragmentPlateSelect = (FrameLayout) findViewById(R.id.fragment_PlateSelect);
        BBS_Plate_Fragment fragment = BBS_Plate_Fragment.newInstance();
        fragment.setStatus(2);
        getSupportFragmentManager().beginTransaction().add(R.id.fragment_PlateSelect, fragment).show(fragment).commit();
    }

    public void setFirstSort(int firstSort, String firstSortName) {
        this.firstSort = firstSort;
        this.firstSortName = firstSortName;
    }

    public void setSecondSort(int secondSort, String secondSortName) {
        this.secondSort = secondSort;
        this.secondSortName = secondSortName;
    }

    public void setPlateSeclect(String plateName) {
        Intent data = new Intent();
        data.putExtra("firstName", firstSortName);
        data.putExtra("secondName", secondSortName);
        data.putExtra("firstID", firstSort);
        data.putExtra("secondID", secondSort);

        setResult(1001, data);
        finish();

    }
}
